There are two optional parameters that are supported by all sections whose entries are separated into parameters except for [Types], [Components] and [Tasks]. These are:
The name of a function that is to be called once just before an entry is installed. The function must either be a custom function in the [Code] section or a support function.
May include a comma separated list of parameters that Setup should pass to the function. Allowed parameter types are String, Integer and Boolean. String parameters may include constants.
There's one support function that may be called from within a parameter list: ExpandConstant.
[Files] Source: "MYPROG.EXE"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall Source: "A\MYFILE.TXT"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall2('{app}\A\MYFILE.TXT') Source: "B\MYFILE.TXT"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall2('{app}\B\MYFILE.TXT') Source: "MYPROG.CHM"; DestDir: "{app}"; BeforeInstall: Log('Before MYPROG.CHM Install')
The name of a function that is to be called once just after an entry is installed. The function must either be a custom function in the [Code] section or a support function.
May include a comma separated list of parameters that Setup should pass to the function. Allowed parameter types are String, Integer and Boolean. String parameters may include constants.
There's one support function that may be called from within a parameter list: ExpandConstant.
[Files] Source: "MYPROG.EXE"; DestDir: "{app}"; AfterInstall: MyAfterInstall Source: "A\MYFILE.TXT"; DestDir: "{app}"; AfterInstall: MyAfterInstall2('{app}\A\MYFILE.TXT') Source: "B\MYFILE.TXT"; DestDir: "{app}"; AfterInstall: MyAfterInstall2('{app}\B\MYFILE.TXT') Source: "MYPROG.CHM"; DestDir: "{app}"; AfterInstall: Log('After MYPROG.CHM Install')
All BeforeInstall and AfterInstall functions must not have a return value.
A BeforeInstall or AfterInstall function isn't called if Setup already determined the entry it shouldn't be processed.
Here is an example of a [Code] section containing the functions used above. Function Log is a support function and therefore not included in this [Code] section.
[Code] procedure MyBeforeInstall(); begin MsgBox('About to install MyProg.exe as ' + CurrentFileName + '.', mbInformation, MB_OK); end; procedure MyBeforeInstall2(FileName: String); begin MsgBox('About to install ' + FileName + ' as ' + CurrentFileName + '.', mbInformation, MB_OK); end; procedure MyAfterInstall(); begin MsgBox('Just installed MyProg.exe as ' + CurrentFileName + '.', mbInformation, MB_OK); end; procedure MyAfterInstall2(FileName: String); begin MsgBox('Just installed ' + FileName + ' as ' + CurrentFileName + '.', mbInformation, MB_OK); end;